package servlet;

import bean.Result;
import com.google.gson.Gson;
import dao.QueryUserdao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

//销户
@WebServlet(name = "DeluserServlet", value = "/deluser.s")
public class DeluserServlet extends HttpServlet {
    QueryUserdao dao =new QueryUserdao();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        final HttpSession session = request.getSession();
        final Integer userid = (Integer) session.getAttribute("userid");
        dao.deluser( userid);
        session.removeAttribute("user");
        session.removeAttribute("userid");
        Result result;
        result=new Result(1,"删除成功",null);

        final String json = new Gson().toJson(result);
        response.getWriter().append(json);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
